//
//  LoginVC.m
//  hnGovernment
//
//  Created by 安仔 on 17/3/3.
//  Copyright © 2017年 安仔. All rights reserved.
//

#import "LoginVC.h"
#import "LoginView.h"

#import "RegisterVC.h"
#import "ForgetPswVC.h"
#import "DDbaseNetWork+Login.h"
#import "DDcacheManager.h"
#import "loginVM.h"


@interface LoginVC ()<LoginViewDelegate>

@property (nonatomic, strong) LoginView *loginView;
@end

@implementation LoginVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = NSLocalString(@"登录");

    self.loginView = [[LoginView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight - 64)];
    self.loginView.delegate = self;
    [self.view addSubview:self.loginView];
}

- (void) clickSureLoginBtn {
    WEAKSELF;
    [loginVM loginWithLoginName:self.loginView.phoneTF.text password:self.loginView.pswTF.text controller:self success:^(id result, DDcacheType cacheType, DDresultType resultType) {
        [cacheManager cacheUserInfo:result[@"data"]];
        [SVProgressHUD dismiss];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [SVProgressHUD showSuccessWithStatus:@"登录成功"];
            [weakSelf.navigationController popViewControllerAnimated:YES];
        });
    }];
}

- (void) clickForgetPswBtn {
    
    ForgetPswVC *forgerPswVC = [[ForgetPswVC alloc] init];
    [self.navigationController pushViewController:forgerPswVC animated:YES];
    
}

- (void) clickRegisterBtn {
    
    RegisterVC *registerVC = [[RegisterVC alloc] init];
    [self.navigationController pushViewController:registerVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - life cycle



#pragma mark - public methods



#pragma mark - target action



#pragma mark - delegates



#pragma mark - pravite methods



#pragma mark - setters



#pragma mark - getters






@end
